<template>
  <div class="my_div">
    <div v-for="(item, index) in arr" :key="index">
      <img src="item.dogImgUrl" alt="" />
      <p
        :class="{ blue: num === 1, red: num === 2, purple: num === 3 }"
        @click="changeColor"
      >
        这是一个孤独可怜的狗
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 0,
    };
  },
  methods: {
    changeColor() {
      this.num++;
      if (this.num === 3) {
        this.num = 0;
      }
    },
  },
};
</script>

<style>
.blue {
  background-color: blue;
}
.red {
  background-color: red;
}
.purple {
  background-color: purple;
}
.my_div {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.my_div img {
  width: 100%;
  height: 200px;
}
</style>